import  { getNestApiData } from "@/services/cpasRequest";

// 获取报告模板
export async function draftList() {
    try {
        const res = await getNestApiData('/draft/list', 'get', {})
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '接口/draft/list,请求失败！',
            success: false,
        });
    }
  }

  
// 判断模板是否重复
export async function queryDraftTemplateIsExistByTemplateName(params: {
    templateName: string
}) {
    try {
        const res = await getNestApiData(`/draft/queryDraftTemplateIsExistByTemplateName?templateName=${params.templateName}`, 'get')
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '接口/draft/queryDraftTemplateIsExistByTemplateName,请求失败！',
            success: false,
        });
    }
  }

// 保存模板
  export async function draftSave(params: {
    MBMC: string,
    dbname: any,
    zcbfid: any,
    sjxmbh: any,
    DGND: string
}) {
    try {
        const res = await getNestApiData('/draft/save', 'post', params)
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '接口/draft/save,请求失败！',
            success: false,
        });
    }
}
  
  